import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from 'path';

export default defineConfig({
  base: "./",
  plugins: [vue()],
  publicPath: "./",
  server: {
    host: "0.0.0.0",
  },
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "src"),
    },
  },
  proxy: {
    // 定义一个代理规则，将/hello-world路径下的请求代理到指定的目标服务器
    "/pl": {
      // 目标服务器的地址
      target: "http://localhost:1200",
      // 更改请求的origin为代理服务器的origin，以便与目标服务器交互
      changeOrigin: true,

      rewrite: (path) => path.replace(/^\/pl/, "/pl"),
    },
  },
  optimizeDeps: { include: ["echarts"] },
  build: {
    assetsInclude: ["**/*.woff", "**/*.ttf"],
    rollupOptions: {
      output: {
        manualChunks: {
          echarts: ["echarts"],
        },
      },
    },
  },
});
